package com.jeesite.modules.rt.entity;

import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;

import com.jeesite.common.lang.DateUtils;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import com.jeesite.common.utils.excel.fieldtype.OfficeType;

/**
 * 跑量Entity
 * @author 李寒冰
 * @version 2024-10-15
 */
@Table(name="rt_device_paoliang", alias="a", label="跑量信息", columns={
		@Column(name="id", attrName="id", label="id", isPK=true),
		@Column(name="sn", attrName="sn", label="SN"),
		@Column(name="kehu_id", attrName="kehuId", label="客户ID", isUpdateForce=true),
		@Column(name="work_date", attrName="workDate", label="查询日期", isUpdateForce=true),
		@Column(name="bandwidth", attrName="bandwidth", label="结算跑量", comment="结算跑量（单位：MB）", isUpdateForce=true),
		@Column(name="amount", attrName="amount", label="收益"),
		@Column(name="online_code", attrName="onlineCode", label="在线状态"),
		@Column(name="province_city", attrName="provinceCity", label="省份城市"),
		@Column(name="heartbeat_num", attrName="heartbeatNum", label="总打点数", isUpdateForce=true),
		@Column(name="night_heartbeat_num", attrName="nightHeartbeatNum", label="晚高峰打点数", isUpdateForce=true),
	}, orderBy="a.id DESC"
)
public class RtDevicePaoliang extends DataEntity<RtDevicePaoliang> {
	
	private static final long serialVersionUID = 1L;
	@ExcelFields({
		@ExcelField(title="SN", attrName="sn", align= ExcelField.Align.CENTER, sort=10),
		@ExcelField(title="时间", attrName="workDate",dataFormat = "yyyy-MM-dd", align= ExcelField.Align.CENTER, sort=20),
		@ExcelField(title="结算跑量", attrName="bandwidth", align= ExcelField.Align.CENTER, sort=30),
		@ExcelField(title="收益", attrName="amount", align= ExcelField.Align.CENTER, sort=40),
		@ExcelField(title="地区", attrName="provinceCity", align= ExcelField.Align.CENTER, sort=50),
		@ExcelField(title="总打点数", attrName="heartbeatNum", align= ExcelField.Align.CENTER, sort=60),
		@ExcelField(title="晚高峰打点数", attrName="nightHeartbeatNum", align= ExcelField.Align.CENTER, sort=70),
	})
	private String sn;		// SN
	private Integer kehuId;		// 客户ID
	private Date workDate;		// 查询日期
	private Double bandwidth;		// 结算跑量（单位：MB）
	private BigDecimal amount;		// 收益
	private String onlineCode;		// 在线状态
	private String provinceCity;		// 省份城市
	private Integer heartbeatNum;		// 总打点数
	private Integer nightHeartbeatNum;		// 晚高峰打点数

	private Integer searchTypePaoliang;
	private Integer searchTypeWan;
	private Integer searchType;

	public Integer getSearchTypePaoliang() {
		return searchTypePaoliang;
	}

	public void setSearchTypePaoliang(Integer searchTypePaoliang) {
		this.searchTypePaoliang = searchTypePaoliang;
	}

	public Integer getSearchTypeWan() {
		return searchTypeWan;
	}

	public void setSearchTypeWan(Integer searchTypeWan) {
		this.searchTypeWan = searchTypeWan;
	}

	public Integer getSearchType() {
		return searchType;
	}

	public void setSearchType(Integer searchType) {
		this.searchType = searchType;
	}

	public RtDevicePaoliang() {
		this(null);
	}
	
	public RtDevicePaoliang(String id){
		super(id);
	}
	
	@Size(min=0, max=255, message="SN长度不能超过 255 个字符")
	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}
	
	public Integer getKehuId() {
		return kehuId;
	}

	public void setKehuId(Integer kehuId) {
		this.kehuId = kehuId;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getWorkDate() {
		return workDate;
	}

	public void setWorkDate(Date workDate) {
		this.workDate = workDate;
	}
	
	public Double getBandwidth() {
		return bandwidth;
	}

	public void setBandwidth(Double bandwidth) {
		this.bandwidth = bandwidth;
	}
	
	@Size(min=0, max=255, message="收益长度不能超过 255 个字符")
	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}
	
	@Size(min=0, max=255, message="在线状态长度不能超过 255 个字符")
	public String getOnlineCode() {
		return onlineCode;
	}

	public void setOnlineCode(String onlineCode) {
		this.onlineCode = onlineCode;
	}
	
	@Size(min=0, max=255, message="省份城市长度不能超过 255 个字符")
	public String getProvinceCity() {
		return provinceCity;
	}

	public void setProvinceCity(String provinceCity) {
		this.provinceCity = provinceCity;
	}
	
	public Integer getHeartbeatNum() {
		return heartbeatNum;
	}

	public void setHeartbeatNum(Integer heartbeatNum) {
		this.heartbeatNum = heartbeatNum;
	}
	
	public Integer getNightHeartbeatNum() {
		return nightHeartbeatNum;
	}

	public void setNightHeartbeatNum(Integer nightHeartbeatNum) {
		this.nightHeartbeatNum = nightHeartbeatNum;
	}

	public void setWorkDateEq(String workDate){
		Date startDate = DateUtils.parseDate(workDate);
		Date endDate = DateUtils.parseDate(workDate+" 23:59:59");
		this.sqlMap.getWhere().and("work_date", QueryType.GTE, startDate)
				.and("work_date", QueryType.LTE, endDate);
	}

	public void setWorkDateGTE(String workDate){
		Date startDate = DateUtils.parseDate(workDate);
		this.sqlMap.getWhere().and("work_date", QueryType.GTE, startDate);
	}

	/**
	 * 晚打点筛选
	 * @param searchTypeWan
	 * @param nightHeartbeatNum
	 */
	public void setNightHeartbeatNumSearch(Integer searchTypeWan, Integer nightHeartbeatNum){
		if(searchTypeWan==1){
			this.sqlMap.getWhere().and("night_heartbeat_num", QueryType.GTE, nightHeartbeatNum);
		}
		if(searchTypeWan==2){
			this.sqlMap.getWhere().and("night_heartbeat_num", QueryType.LTE, nightHeartbeatNum);
		}
		if(searchTypeWan==0){
			this.sqlMap.getWhere().and("night_heartbeat_num", QueryType.EQ, nightHeartbeatNum);
		}
	}

	/**
	 * 总打点数筛选
	 * @param searchType
	 * @param heartbeatNum
	 */
	public void setHeartbeatNumSearch(Integer searchType, Integer heartbeatNum){
		if(searchType==1){
			this.sqlMap.getWhere().and("heartbeat_num", QueryType.GTE, heartbeatNum);
		}
		if(searchType==2){
			this.sqlMap.getWhere().and("heartbeat_num", QueryType.LTE, heartbeatNum);
		}
		if(searchType==0){
			this.sqlMap.getWhere().and("heartbeat_num", QueryType.EQ, heartbeatNum);
		}
	}

	/**
	 * 结算跑量筛选
	 * @param searchTypePaoliang
	 * @param bandwidth
	 */
	public void setBandwidthSearch(Integer searchTypePaoliang, Double bandwidth){
		if(searchTypePaoliang==1){
			this.sqlMap.getWhere().and("bandwidth", QueryType.GTE, bandwidth);
		}
		if(searchTypePaoliang==2){
			this.sqlMap.getWhere().and("bandwidth", QueryType.LTE, bandwidth);
		}
		if(searchTypePaoliang==0){
			this.sqlMap.getWhere().and("bandwidth", QueryType.EQ, bandwidth);
		}
	}
}